package com.xuelang.pipeline.client.task;

import com.xuelang.pipeline.client.common.constant.DictDTO;
import com.xuelang.pipeline.client.common.request.PageParam;
import com.xuelang.pipeline.client.common.result.ApiResult;
import com.xuelang.pipeline.client.common.result.PageRecord;
import com.xuelang.pipeline.client.task.dto.DeployTaskConfigDTO;
import com.xuelang.pipeline.client.task.dto.TaskDTO;
import com.xuelang.pipeline.client.task.dto.TaskQuery;
import com.xuelang.pipeline.client.task.dto.TaskVerifyUserPageQuery;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;
import java.util.List;

/**
 * 流水线任务服务API
 *
 * @author xiwen.zxg
 * @since 2024/5/15
 */
public interface ITaskService {

    /**
     * 查询流水线任务列表(有过滤条件，可以分页)
     *
     * @param dtoPageParam
     * @return
     */
    @PostMapping(value = "/pageList", produces = "application/json;charset=utf-8")
    ApiResult<PageRecord<TaskDTO>> pageTaskList(@RequestBody @Valid PageParam<TaskQuery> dtoPageParam);

    /**
     * 查询流水线任务列表(有过滤条件)
     *
     * @param taskQuery
     * @return
     */
    @PostMapping(value = "/list", produces = "application/json;charset=utf-8")
    ApiResult<List<TaskDTO>> conditionalTaskList(@RequestBody @Valid TaskQuery taskQuery);

    /**
     * 新增流水线任务
     *
     * @param taskDTO
     * @return
     */
    @PostMapping(value = "", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> addTask(@RequestBody @Valid TaskDTO taskDTO);

    /**
     * 更新流水线任务
     *
     * @param taskDTO
     * @return
     */
    @PutMapping(value = "", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> updateTask(@RequestBody @Valid TaskDTO taskDTO);

    /**
     * 删除流水线任务
     *
     * @param uuid
     * @return
     */
    @DeleteMapping(value = "/{uuid}", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> deleteTask(@PathVariable("uuid") String uuid);

    /**
     * 查询流水线任务
     *
     * @param uuid
     * @return
     */
    @GetMapping(value = "/{uuid}", produces = "application/json;charset=utf-8")
    ApiResult<TaskDTO> queryTask(@PathVariable("uuid") String uuid);

    /**
     * 查询流水线红线任务字典
     *
     * @param
     * @return
     */
    @GetMapping(value = "/redline/dict", produces = "application/json;charset=utf-8")
    ApiResult<List<DictDTO>> queryRedLineTaskDict();

    /**
     * 查询流水线红线任务字典
     *
     * @param
     * @return
     */
    @PostMapping(value = "/deploy/advanced/config", produces = "application/json;charset=utf-8")
    ApiResult<String> queryDeployAdvancedConfig(@RequestBody @Valid DeployTaskConfigDTO deployTaskConfigDTO);


    /**
     * 获取用户下拉列表字典
     *
     * @param pageParam @return
     */
    @PostMapping(value = "/verifier/user/dict", produces = "application/json;charset=utf-8")
    ApiResult<PageRecord<DictDTO>> queryVerifyUserDict(@RequestBody TaskVerifyUserPageQuery pageParam);

    /**
     * 获取部署任务的部署策略
     *
     * @return
     */
    @PostMapping(value = "/deploy/strategy/dict", produces = "application/json;charset=utf-8")
    ApiResult<List<DictDTO>> queryDeployTaskDict();
}
